<?php
namespace App\Http\Requests;
use App\Models\User;
use Illuminate\Foundation\Http\FormRequest;
class RegisterFormRequest extends FormRequest{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name'  =>  "required|between:2,20",
            'password'  =>  "required|between:6,20",
            'sex'=>"required",
            'mobile'=>"required",
            'code'=>'required'
        ];
    }

    public function attributes(){
        return [
            "name"  =>  "姓名",
            "password"  =>  "初始密码",
            'sex'=>"性别",
            'mobile'=>"手机号码",
            'code'=>"验证码"

        ];
    }

    public function messages(){
        return [
            "required"  =>  ":attribute 必填",
            "between"   =>  ":attribute 长度需为 :min 至 :max 字符",
            "unique"    =>  ":attribute 已存在",
            "email"     =>  "电子邮箱格式不正确"
        ];
    }
}